Conversation
|
I will merge this into #6 once approved. Keeping the PRs small to handle. |
|
Questions for @brili while I went through this one. Is there a specific reason why we inherit from built-in |
|
|
||
| # Early exit for initialized nodes | ||
| if self.initialized: | ||
| return |
There was a problem hiding this comment.
you need to assign valid kwargs to self at this point and then return
There was a problem hiding this comment.
yes but we need to make sure not to include the extra fields that the api returns, you can refactor the retrieve_by_uuid and create a separate method from
allowed_data = {}
for key in data:
if key in self.__dict__["schema"]["$defs"][f"{self.__class__.__name__}Post"]["properties"]:
setattr(self, key, data[key])
allowed_data[key] = data[key]
self.__dict__["__original__"] = copy.deepcopy(allowed_data)
There was a problem hiding this comment.
Thanks for the pointers.
I used that snippet to refactor it a little bit.
I think there is some room to streamline this a little bit.
But we can address that in a refactor down the line.
@brili please check if that is along the lines of what you had in mind.
Tests are passing on my end.
(I also see that @izaim added a branch for CI tests here, probably coming soon.)
I am skipping
CriptNode.final_updateif the node is notinitialized.I added a test that uses Materials from a search, which get successfully converted to nodes.
We may want to try other types of classes too.
I am open to making the new private functions.
CriptNode._from_dictCriptNode._cls_from_dictpublic. I would like to know what you think for the design and user experience.
@Ardi028 for visibility.